% OTF2D.m
% author: Kevin O'Holleran
%
% Description: creates a 2D OTF for an incoherent imaging system with an
% incoherent cutoff given by r0. This equation is taken from Fourier Optics
% by Goodman.
% 
% param r0 double, incoherent cutoff as ratio of matrix width
% paran n integer, for creating (n x n) matrix
function [ otf ] = OTF2D( r0,n)

x = -2:(4/(n-1)):2;

[X Y] = meshgrid(x);
[angle,mag] = cart2pol(X,Y);
idx = mag <= 2*r0;

otf = zeros(n,n);

dum =  2/pi*(acos(mag/(2*r0)) - (mag/(2*r0)).*sqrt(1-(mag/(2*r0)).^2));
otf(idx) = dum(idx);

end

